package com.example.springbootsfzy.service.gengminghui;

import com.example.springbootsfzy.domain.CourseReviews;
import com.example.springbootsfzy.mapper.CourseReviewsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseReviewsService {

    @Autowired
    private CourseReviewsMapper courseReviewsMapper;

    public List<CourseReviews> selectAll() {
        return courseReviewsMapper.selectAll();
    }

    //通过课程id查询所有评论和用户昵称
    public List<CourseReviews> selectByCourseId(Integer id) {
        List<CourseReviews> courseReviews = courseReviewsMapper.selectByCourseId(id);
        return courseReviews;
    }
    //通过id删除
    public int deleteById(Integer id) {
        return courseReviewsMapper.deleteByPrimaryKey(id);
    }

    //添加
    public int insert(CourseReviews courseReviews) {
        return courseReviewsMapper.insert(courseReviews);
    }
    //修改
    public int update(CourseReviews courseReviews) {
        return courseReviewsMapper.updateByPrimaryKeySelective(courseReviews);
    }

    //通过咨询师id查询对应的评论
    public List<CourseReviews> selectByConsultantId(Integer id) {
        return courseReviewsMapper.selectByConsultantId(id);    }

}
